package ss.pku.meeting;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import lava.rt.persistence.sql.src.DataContextSrcGener;
import lava.rt.persistence.sql.src.MySQLDataContextSrcGener;
import ss.pku.meeting.dc.MeetingDataContext;
import ss.pku.meeting.dc.MeetingDataContextBase;

public class MettingDataContextGener {

	
	public static void main(String[] args) throws SQLException, IOException {
		// TODO Auto-generated method stub
		    
		    MysqlDataSource dataSource=new MysqlDataSource();
		    dataSource.setUrl("jdbc:mysql://localhost:3306/meeting?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");
		    dataSource.setUser("root");
		    dataSource.setPassword("admin");
		

		   Connection connection=dataSource.getConnection();
		
		    //根据数据库类型选择对应SrcGener
			DataContextSrcGener srcGener=new MySQLDataContextSrcGener(connection);
		
			//指定生成src的根本目录
			String projectDir="E:\\metting\\MeetingRoom\\BackEnd\\src\\main\\java";
			
			//在src里创建接口和抽象类，如下面的 RenrenAdminDataContext（接口），RenrenAdminDataContextBase（基类），不用添加任何内容
	
			
			//方案2  简易直接生成接口和基类
	        srcGener.saveAllTo(projectDir,MeetingDataContext.class,MeetingDataContextBase.class,"meeting");
	}

	
}
